package com.spring.test.service.impl;

import com.spring.test.entity.User;
import com.spring.test.mapper.UserMapper;
import com.spring.test.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.apache.shiro.web.filter.mgt.DefaultFilter.user;

/**
 * @Author wangjie
 * @Version V1.0.0
 * @Date Created in 2022/3/8 0008
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    @Override
    public List<Object> getUserList() {
        System.out.println("userMapper.getUserList() = " + userMapper.getUserList());
        return userMapper.getUserList();
    }

    //注册用户
    @Override
    public int setUser(User user) {

        int i = userMapper.setUser(user);
        return i;
    }
//查找几个同名
    @Override
    public int checkUserName(String username) {

        return userMapper.selectUserName(username);
    }
//比较密码
    @Override
    public boolean checkUserNameAndPwd(String username, String password) {
        System.out.println("username = " + username);
        System.out.println("password = " + password);
        String passworddb = userMapper.findPwdByUserName(username);
        if(passworddb.equals(password)){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<Object> getUserInfo(String username) {
       return userMapper.selectUserInfoByName(username);
    }

    @Override
    public int updateUserInfo(User user) {
        return userMapper.updateUserInfo(user);
    }


}
